use std::time::Instant;

use l2dg::app::App;
use l2dg::view::Label;
use l2dg::view::{Button, Input, VerticalLayout};

struct AppData {
    pub counter: i32,
    pub label: String,
    pub start: Instant,
}

fn main() {
    let app_data = AppData {
        counter: 0,
        label: "Hello".to_string(),
        start: Instant::now(),
    };
    let app = App::new(
        |state: &mut AppData| {
            let secs = state.start.elapsed().as_secs();
            VerticalLayout::new((
                Button::new(state.counter.to_string(), |data: &mut AppData| {
                    data.counter += 10
                }),
                Input::new(),
                Label::new(format!("{}", secs)).with_color([0.0, 0.0, 1.0, 1.0]),
                Button::new(state.counter.to_string(), |data: &mut AppData| {
                    data.counter += 1
                }),
            ))
        },
        app_data,
    );
    app.run();
}
